package edu.osu.cse.c651.cryptochess;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * This class represents the GUI of our application; users interact with it to
 * play chess.
 * 
 * @author Team Pawned
 * 
 */
public class GameActivity extends Activity {

	/**
	 * Used to debug
	 */
	public static String TAG = "CryptoChess";

	/**
	 * The int ids of each square of the game board
	 */
	private int[][] gridIds;

	/**
	 * The user of this GUI and application
	 */
	private User user;

	/**
	 * The opponent of this player
	 */
	private User opponent;

	/**
	 * The color of this player (Color.WHITE or Color.BLACK)
	 */
	private Color color;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.game);
		Log.d(TAG, "Just set the Content View");

		/*user = (User) this.getIntent().getSerializableExtra("user");
		opponent = (User) this.getIntent().getSerializableExtra("opponent");
		color = (Color) this.getIntent().getSerializableExtra("color");
		InetAddress addr = (InetAddress) this.getIntent().getSerializableExtra(
				"ip");
		opponent.setIpAddress(addr);

		User darkUser;
		User lightUser;
		if (color == Color.WHITE) {
			lightUser = user;
			darkUser = opponent;
		} else {
			lightUser = opponent;
			darkUser = user;
		}

		View lightUserLayout = findViewById(R.id.gameLightUser);
		View darkUserLayout = findViewById(R.id.gameDarkUser);

		TextView lightUsername = (TextView) lightUserLayout
				.findViewById(R.id.textUsername);
		TextView lightRating = (TextView) lightUserLayout
				.findViewById(R.id.textRating);
		TextView lightWinLoss = (TextView) lightUserLayout
				.findViewById(R.id.textWinLoss);
		ImageView lightUserIcon = (ImageView) lightUserLayout
				.findViewById(R.id.imageUserIcon);

		lightUsername.setText("" + lightUser.getUsername());
		lightRating.setText("" + lightUser.getRating());
		lightWinLoss
				.setText("" + lightUser.getWins() + " W - "
						+ lightUser.getLosses() + " L - "
						+ lightUser.getDraws() + " D");
		lightUserIcon.setImageResource(lightUser.getUserIcon().getIconId());

		TextView darkUsername = (TextView) darkUserLayout
				.findViewById(R.id.textUsername);
		TextView darkRating = (TextView) darkUserLayout
				.findViewById(R.id.textRating);
		TextView darkWinLoss = (TextView) darkUserLayout
				.findViewById(R.id.textWinLoss);
		ImageView darkUserIcon = (ImageView) darkUserLayout
				.findViewById(R.id.imageUserIcon);

		darkUsername.setText("" + darkUser.getUsername());
		darkRating.setText("" + darkUser.getRating());
		darkWinLoss.setText("" + darkUser.getWins() + " W - "
				+ darkUser.getLosses() + " L - " + darkUser.getDraws() + " D");
		darkUserIcon.setImageResource(darkUser.getUserIcon().getIconId());

		((TextView) findViewById(R.id.titleText)).setText("You are " + color);*/
	}
}